﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using MySql.Data;
using MySql.Data.MySqlClient;

namespace DataAccess
{
    public class Checkin
    {
        private string _roomID;
        private string _roomType;
        private double _roomPrice;
        private string _personName;
        private string _personID;
        private string _sex;
        private string _checkTime;
        private string _roomStatus;

        #region
        public string roomID
        {
            get { return _roomID; }
            set { _roomID = value; }
        }

        public string roomType
        {
            get { return _roomType; }
            set { _roomType = value; }
        }

        public double roomPrice
        {
            get { return _roomPrice; }
            set { _roomPrice = value; }
        }

        public string personName
        {
            get { return _personName; }
            set { _personName = value; }
        }
        public string personID
        {
            get { return _personID; }
            set { _personID = value; }
        }
        public string Sex
        {
            get { return _sex; }
            set { _sex = value; }
        }
        public string checkTime
        {
            get { return _checkTime; }
            set { _checkTime = value; }
        }
        public string roomStatus
        {
            get { return _roomStatus; }
            set { _roomStatus = value; }
        }


        #endregion

        public static int AddPerson(Checkin ck)
        {
            string sql = "insert into userinfo(roomId, roomType, roomPrice,personName,personId,personSex,checkinDate,roomStatus) values (@roomid,@roomtype,@roomprice,@personname,@personid,@personsex,@checkindate,@roomstatus)";
            MySqlParameter[] commandParameters = { new MySqlParameter("@roomID", ck._roomID), new MySqlParameter("@roomType", ck._roomType), new MySqlParameter("@roomPrice", ck._roomPrice), new MySqlParameter("@personName", ck._personName), new MySqlParameter("@personId", ck._personID), new MySqlParameter("@personSex", ck._sex), new MySqlParameter("@checkinDate", ck._checkTime), new MySqlParameter("@roomStatus", ck._roomStatus) };
            int result = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sql, commandParameters);
            return result;
        }

        public static int updateroom()
        {
            string sql = "update roomstatus rs,userinfo u set rs.roomStatus = u.roomStatus where rs.roomId = u.roomId";
            int result = MySqlHelper.ExecuteNonQuery(MySqlHelper.Conn, CommandType.Text, sql, null);
            return result;
        }
    }
}
